package com.itheima.exception;

import com.itheima.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class GlobalExcepion {
    @ExceptionHandler
    public Result error(BusinessException e){
        log.error("出现异常：{}",e);
        return Result.error(e.getMessage());
    }
    @ExceptionHandler
    public Result error(Exception e){
        log.error("出现异常：{}",e);
        return Result.error("服务器异常");
    }
}
